package com.gs.synedocket.presenter;

import com.gs.synedocket.apiresult.ApiResultData;
import com.gs.synedocket.model.SyncModel;
import com.gs.synedocket.model.listener.OnResultListener;
import com.gs.synedocket.view.IMainView;
import com.gs.synedocket.view.ISyncTable;

import java.util.List;

public class SyncTablePresenter extends BasePresenter<ISyncTable> {
    private SyncModel syncModel = new SyncModel();


    public void syncModel(String table, Class typeofT) {
        syncModel.sync(table, new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onSyncTableSuccess((ApiResultData<List<Object>>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onSyncTableFails(e);
                }
            }
        }, typeofT);
    }
}
